<template>
	<a-card style="margin: -15px">
		<!--会员查询条件-->
		<a-row style="margin-bottom: 1rem">
			<!--放置搜索条件-->
			<a-col :span="3">
				<a-select
					ref="select"
					v-model:value="this.page.status"
					style="width: 80px;margin-top: 4px"
					@focus="focus"
					@change="handleChange"
					placeholder="状态"
				>
					<a-select-option value="0">禁用</a-select-option>
					<a-select-option value="1">启用</a-select-option>
					<a-select-option value="">全部</a-select-option>

				</a-select>
			</a-col>
			<a-col :span="6">
				<a-input-search
					v-model:value="this.page.keyword"
					placeholder="搜索关键字"
					enter-button="搜索"
					size="large"
					@search="onSearch"
				/>
			</a-col>
			<a-col :push=this.number :span="3">
				<a-button type="primary" style="width: 90px;height: 40px" @click="addMb">
					<PlusOutlined />
					添加
				</a-button>
			</a-col>


		</a-row>
		<!--会员列表-->
		<a-row style="margin-bottom: 1rem">
			<a-col :span="24">
				<a-table :columns="columns" :data-source="data" :pagination="false">

					<template #bodyCell="{ column, record}">
						<template v-if="column.key === 'isKyc'">
							<a-tag v-if="record.isKyc==0" :bordered="false" color="default">未实名</a-tag>
							<a-tag v-if="record.isKyc==1" :bordered="false" color="success">已实名</a-tag>
						</template>
						<template v-if="column.key === 'accInfo'">
							<a-row style="margin-top: 0.5rem">
								<a-col>
									<a-avatar :size="64" :src=record.uuidAvatar @click="getMb(record.id)">
										<template #icon>
											<UserOutlined />
										</template>
									</a-avatar>
								</a-col>
								<a-col style="margin-left: 10px;margin-top: 10px">
									<span>{{ record.nickname }}</span>
									<br />
									<span>{{ record.phone }}</span>
								</a-col>
							</a-row>
						</template>
						<template v-if="column.key === 'action'">

							<a-dropdown>
								<!--禁用未实名-->
								<template #overlay v-if="record.userStatus==='DISABLED' && record.isKyc==0 ">
									<a-menu>
										<a-menu-item key="3" @click="updateMb(record.id)">修改</a-menu-item>
										<a-menu-item key="4" @click="getMbInfo(record.id)">查看</a-menu-item>
										<a-menu-item key="5" @click="del(record.id)">删除</a-menu-item>
										<a-menu-item key="7" @click="start(record.id)">启用</a-menu-item>
									</a-menu>
								</template>
								<!--禁用已实名-->
								<template #overlay v-if="record.userStatus==='ENABLE' &&record.isKyc==1">
									<a-menu>
										<a-menu-item key="3" @click="updateMb(record.id)">修改</a-menu-item>
										<a-menu-item key="4" @click="getMbInfo(record.id)">查看</a-menu-item>
										<a-menu-item key="5" @click="del(record.id)">删除</a-menu-item>
										<a-menu-item key="7" @click="start(record.id)">启用</a-menu-item>
										<a-menu-item key="10" @click="kyc(record.id)">实名认证</a-menu-item>
										<a-menu-item key="11" @click="mbAccount(record.id)">会员账户</a-menu-item>
									</a-menu>
								</template>
								<!--启用未实名-->
								<template #overlay v-if="record.userStatus==='ENABLE'&&record.isKyc==0">
									<a-menu>
										<a-menu-item key="1" @click="getMbInfo(record.id)">查看</a-menu-item>
										<a-menu-item key="2" @click="dis(record.id)">禁用</a-menu-item>
									</a-menu>
								</template>
								<!--启用已实名-->
								<template #overlay v-if="record.userStatus==='ENABLE'&&record.isKyc==1">
									<a-menu>
										<a-menu-item key="1" @click="getMbInfo(record.id)">查看</a-menu-item>
										<a-menu-item key="2" @click="dis(record.id)">禁用</a-menu-item>
										<a-menu-item key="10" @click="kyc(record.id)">实名认证</a-menu-item>
										<a-menu-item key="11" @click="mbAccount(record.id)">会员账户</a-menu-item>
									</a-menu>
								</template>

								<a-button>
									操作
									<DownOutlined />
								</a-button>
							</a-dropdown>


						</template>
						<template v-if="column.key === 'userStatus'">
							<a-tag v-if="record.userStatus==='DISABLED'" :bordered="false" color="default">禁用</a-tag>
							<a-tag v-if="record.userStatus==='ENABLE'" :bordered="false" color="success">启用</a-tag>
						</template>

					</template>
				</a-table>
			</a-col>
		</a-row>
		<!--分页组件-->
		<a-flex justify="flex-end">
			<a-pagination
				size="small"
				@change="onChange"
				show-size-changer
				:pageSizeOptions="['5','10','20','50','100']"
				v-model:current="this.page.pageNo"
				v-model:page-size="this.page.pageSize"
				:total="this.page.total"
				:show-total="(total, range) => `${range[0]}-${range[1]} 共 ${total} 条`" />
		</a-flex>
	</a-card>
	<!--  添加抽屉-->
	<a-drawer
		title="添加会员信息"
		:width="750"
		:open="addOpen"
		:body-style="{ paddingBottom: '80px' }"
		:footer-style="{ textAlign: 'right' }"
		@close="addOnClose"
	>
		<template #extra>
			<a-button style="margin-right: 8px" @click="addOnClose()">取消</a-button>
			<a-button type="primary" @click="saveMb()">保存</a-button>
		</template>
		<!--添加的表单-->
		<a-form :model="addMbInfo" ref="formRef" :label-col="labelCol" :wrapper-col="wrapperCol">
			<!--会员头像-->
			<a-row :gutter="16">
				<a-col :span="16">
					<a-form-item ref="avatar" label="会员头像:" name="avatar">
						<a-upload
							:beforeUpload="beforeUpload"
							:customRequest="onUpload"
							:max-count="1"
							:show-upload-list="true"
							class="avatar-uploader"
							list-type="picture-card"
							name="avatar"
							@change="customRequestMinio">
							<div>
								<PlusOutlined />
							</div>
						</a-upload>
					</a-form-item>
				</a-col>
			</a-row>
			<a-card title="基本信息" style="width: 100%">
				<!-- 昵称，账号-->
				<a-row :gutter="24">
					<a-col :span="12">
						<a-form-item label="昵称:" labelWrap="false" name="nickname"
									 :rules="[{ required: true, message: '会员昵称不能为空!'}]">
							<a-input v-model:value="addMbInfo.nickname" />
						</a-form-item>
					</a-col>
					<a-col :span="12">
						<a-form-item label="账号:" name="account"
									 :rules="[{ required: true, message: '会员账号不能为空!'}]">
							<a-input v-model:value="addMbInfo.account" />
						</a-form-item>
					</a-col>
				</a-row>

				<!-- 姓名，性别-->
				<a-row :gutter="24">
					<a-col :span="12">
						<a-form-item label="姓名:">
							<a-input v-model:value="addMbInfo.userName" />
						</a-form-item>
					</a-col>
					<a-col :span="12">
						<a-form-item ref="gender" label="性别:" name="gender">
							<a-radio-group v-model:value="addMbInfo.gender">
								<a-radio value="0">男</a-radio>
								<a-radio value="1">女</a-radio>
							</a-radio-group>
						</a-form-item>
					</a-col>
				</a-row>

				<!-- 年龄，出生日期-->
				<a-row :gutter="24">
					<a-col :span="12">
						<a-form-item label="年龄:">
							<a-input v-model:value="addMbInfo.age" />
						</a-form-item>
					</a-col>
					<a-col :span="12">
						<a-form-item
							label="出生日期:"
							name="birthday"
						>
							<a-space direction="vertical" :size="12">
								<a-date-picker placeholder="请选择出生日期" @change="onChanger" @ok="onOk"
											   v-model:value="addMbInfo.birthday" value-format="YYYY-MM-DD" />
							</a-space>
						</a-form-item>
					</a-col>
				</a-row>

				<!-- 民族，籍贯-->
				<a-row :gutter="24">
					<a-col :span="12">
						<a-form-item label="民族:">
							<a-select
								v-model:value="addMbInfo.nation" show-search :options="nationInfo.nationDict"
								:field-names="nationInfo.nationNames"
								option-filter-prop="dictLable" placeholder="请选择民族" style="width:100%">
							</a-select>
						</a-form-item>
					</a-col>
					<a-col :span="12">
						<a-form-item label="籍贯:">
							<a-input v-model:value="addMbInfo.nativePlace" />
						</a-form-item>
					</a-col>
				</a-row>

				<!-- 家庭住址，通讯地址-->
				<a-row :gutter="24">
					<a-col :span="12">
						<a-form-item label="家庭住址:">
							<a-input v-model:value="addMbInfo.homeAddress" />
						</a-form-item>
					</a-col>
					<a-col :span="12">
						<a-form-item label="通讯地址:">
							<a-input v-model:value="addMbInfo.mailingAddress" />
						</a-form-item>
					</a-col>
				</a-row>
				<!-- 状态-->
				<a-row :gutter="24">
					<a-col :span="12">
						<a-form-item ref="userStatus" label="状态:" name="userStatus">
							<a-radio-group v-model:value="addMbInfo.userStatus">
								<a-radio value="0">禁用</a-radio>
								<a-radio value="1">启用</a-radio>
							</a-radio-group>
						</a-form-item>
					</a-col>

				</a-row>

			</a-card>
			<br />
			<a-card title="教育经历" style="width: 100%">
				<!--文化程度，政治面貌-->
				<a-row :gutter="24">
					<a-col :span="12">
						<a-form-item label="文化程度:">
							<a-select
								v-model:value="addMbInfo.cultureLevel" show-search
								:options="cultureLevelInfo.cultureLevelDict"
								:field-names="cultureLevelInfo.cultureLevelNames"
								option-filter-prop="dictLable" placeholder="请选择文化程度" style="width:100%">
							</a-select>
						</a-form-item>
					</a-col>
					<a-col :span="12">
						<a-form-item label="政治面貌:">
							<a-select
								v-model:value="addMbInfo.politicalOutlook" show-search
								:options="politicsInfo.politicsDict"
								:field-names="politicsInfo.politicsNames"
								option-filter-prop="dictLable" placeholder="请选择政治面貌" style="width:100%">
							</a-select>
						</a-form-item>
					</a-col>
				</a-row>

				<!-- 毕业院校，学历-->
				<a-row :gutter="24">
					<a-col :span="12">
						<a-form-item label="毕业院校:">
							<a-input v-model:value="addMbInfo.college" />
						</a-form-item>
					</a-col>
					<a-col :span="12">
						<a-form-item label="学历:">
							<a-select
								v-model:value="addMbInfo.education" show-search
								:options="cultureLevelInfo.cultureLevelDict"
								:field-names="cultureLevelInfo.cultureLevelNames"
								option-filter-prop="dictLable" placeholder="请选择学历" style="width:100%">
							</a-select>
						</a-form-item>
					</a-col>
				</a-row>

				<!-- 学制，学位-->
				<a-row :gutter="24">
					<a-col :span="12">
						<a-form-item label="学制:">
							<a-input v-model:value="addMbInfo.eduLength" />
						</a-form-item>
					</a-col>
					<a-col :span="12">
						<a-form-item label="学位:">
							<a-select
								v-model:value="addMbInfo.degree" show-search :options="degreeInfo.degreeDict"
								:field-names="degreeInfo.degreeNames"
								option-filter-prop="dictLable" placeholder="请选择学位" style="width:100%">
							</a-select>
						</a-form-item>
					</a-col>
				</a-row>
			</a-card>
			<br />
			<a-card title="联系方式" style="width: 100%">
				<!--手机，邮箱-->
				<a-row :gutter="24">
					<a-col :span="12">
						<a-form-item label="手机:" labelWrap="false" name="phone"
									 :rules="[{ required: true, message: '手机号不能为空!'},{ pattern:/^1[3456789]\d{9}$/,message: '请输入正确的手机号格式'}]">
							<a-input v-model:value="addMbInfo.phone" />
						</a-form-item>
					</a-col>
					<a-col :span="12">
						<a-form-item label="邮箱:">
							<a-input v-model:value="addMbInfo.email" />
						</a-form-item>
					</a-col>
				</a-row>

				<!-- 家庭电话，办公电话-->
				<a-row :gutter="24">
					<a-col :span="12">
						<a-form-item label="家庭电话:">
							<a-input v-model:value="addMbInfo.homeTel" />
						</a-form-item>
					</a-col>
					<a-col :span="12">
						<a-form-item label="办公电话:">
							<a-input v-model:value="addMbInfo.officeTel" />
						</a-form-item>
					</a-col>
				</a-row>

				<!-- 紧急联系人，紧急联系人电话-->
				<a-row :gutter="24">
					<a-col :span="12">
						<a-form-item label="紧急联系人:">
							<a-input v-model:value="addMbInfo.emergencyContact" />
						</a-form-item>
					</a-col>
					<a-col :span="12">
						<a-form-item label="紧急联系人电话:">
							<a-input v-model:value="addMbInfo.emergencyPhone" />
						</a-form-item>
					</a-col>
				</a-row>

				<!-- 紧急联系人地址-->
				<a-row :gutter="24">
					<a-col :span="12">
						<a-form-item label="紧急联系人地址:">
							<a-input v-model:value="addMbInfo.emergencyAddress" />
						</a-form-item>
					</a-col>
				</a-row>
			</a-card>
		</a-form>
	</a-drawer>
	<!--  修改抽屉-->
	<a-drawer
		title="修改会员信息"
		:width="750"
		:open="updateOpen"
		:body-style="{ paddingBottom: '80px' }"
		:footer-style="{ textAlign: 'right' }"
		@close="updateOnClose"
	>
		<template #extra>
			<a-button style="margin-right: 8px" @click="updateOnClose()">取消</a-button>
			<a-button type="primary" @click="saveUpdateMb()">保存</a-button>
		</template>
		<!--添加的表单-->
		<a-form :model="updateMbInfo" ref="formRef" :label-col="labelCol" :wrapper-col="wrapperCol">

			<!--会员头像-->
			<a-row :gutter="16">
				<a-col :span="16">
					<a-form-item ref="avatar" label="会员头像:" name="avatar">
						<a-upload
							:beforeUpload="beforeUpload"
							:customRequest="onUpload"
							:max-count="1"
							:show-upload-list="true"
							class="avatar-uploader"
							list-type="picture-card"
							name="avatar"
							@change="editCustomRequestMinio"
							:file-list="fileList">
							<div>
								<PlusOutlined />
							</div>
						</a-upload>
					</a-form-item>
				</a-col>
			</a-row>
			<a-card title="基本信息" style="width: 100%">
				<!-- 昵称，账号-->
				<a-row :gutter="24">
					<a-col :span="12">
						<a-form-item label="昵称:">
							<a-input v-model:value="updateMbInfo.nickname" />
						</a-form-item>
					</a-col>
					<a-col :span="12">
						<a-form-item label="账号:">
							<a-input v-model:value="updateMbInfo.account" />
						</a-form-item>
					</a-col>
				</a-row>

				<!-- 姓名，性别-->
				<a-row :gutter="24">
					<a-col :span="12">
						<a-form-item label="姓名:">
							<a-input v-model:value="updateMbInfo.name" />
						</a-form-item>
					</a-col>
					<a-col :span="12">
						<a-form-item ref="gender" label="性别:" name="gender">
							<a-radio-group v-model:value="updateMbInfo.gender">
								<a-radio value="0">男</a-radio>
								<a-radio value="1">女</a-radio>
							</a-radio-group>
						</a-form-item>
					</a-col>
				</a-row>

				<!-- 年龄，出生日期-->
				<a-row :gutter="24">
					<a-col :span="12">
						<a-form-item label="年龄:">
							<a-input v-model:value="updateMbInfo.age" />
						</a-form-item>
					</a-col>
					<a-col :span="12">
						<a-form-item
							label="出生日期:"
							name="birthday"
						>
							<a-space direction="vertical" :size="12">
								<a-date-picker show-time placeholder="请选择出生日期" @change="onChanger" @ok="onOk"
											   v-model:value="updateMbInfo.birthday" value-format="YYYY-MM-DD" />
							</a-space>
						</a-form-item>
					</a-col>
				</a-row>

				<!-- 民族，籍贯-->
				<a-row :gutter="24">
					<a-col :span="12">
						<a-form-item label="民族:">
							<a-select
								v-model:value="updateMbInfo.nation" show-search :options="nationInfo.nationDict"
								:field-names="nationInfo.nationNames"
								option-filter-prop="dictLable" placeholder="请选择民族" style="width:100%">
							</a-select>
						</a-form-item>
					</a-col>
					<a-col :span="12">
						<a-form-item label="籍贯:">
							<a-input v-model:value="updateMbInfo.nativePlace" />
						</a-form-item>
					</a-col>
				</a-row>

				<!-- 家庭住址，通讯地址-->
				<a-row :gutter="24">
					<a-col :span="12">
						<a-form-item label="家庭住址:">
							<a-input v-model:value="updateMbInfo.homeAddress" />
						</a-form-item>
					</a-col>
					<a-col :span="12">
						<a-form-item label="通讯地址:">
							<a-input v-model:value="updateMbInfo.mailingAddress" />
						</a-form-item>
					</a-col>
				</a-row>


			</a-card>
			<br />
			<a-card title="教育经历" style="width: 100%">
				<!--文化程度，政治面貌-->
				<a-row :gutter="24">
					<a-col :span="12">
						<a-form-item label="文化程度:">
							<a-select
								v-model:value="updateMbInfo.cultureLevel" show-search
								:options="cultureLevelInfo.cultureLevelDict"
								:field-names="cultureLevelInfo.cultureLevelNames"
								option-filter-prop="dictLable" placeholder="请选择文化程度" style="width:100%">
							</a-select>

						</a-form-item>
					</a-col>
					<a-col :span="12">
						<a-form-item label="政治面貌:">
							<a-select
								v-model:value="updateMbInfo.politicalOutlook" show-search
								:options="politicsInfo.politicsDict"
								:field-names="politicsInfo.politicsNames"
								option-filter-prop="dictLable" placeholder="请选择政治面貌" style="width:100%">
							</a-select>
						</a-form-item>
					</a-col>
				</a-row>

				<!-- 毕业院校，学历-->
				<a-row :gutter="24">
					<a-col :span="12">
						<a-form-item label="毕业院校:">
							<a-input v-model:value="updateMbInfo.college" />
						</a-form-item>
					</a-col>
					<a-col :span="12">
						<a-form-item label="学历:">
							<a-select
								v-model:value="updateMbInfo.education" show-search
								:options="cultureLevelInfo.cultureLevelDict"
								:field-names="cultureLevelInfo.cultureLevelNames"
								option-filter-prop="dictLable" placeholder="请选择学历" style="width:100%">
							</a-select>
						</a-form-item>
					</a-col>
				</a-row>

				<!-- 学制，学位-->
				<a-row :gutter="24">
					<a-col :span="12">
						<a-form-item label="学制:">
							<a-input v-model:value="updateMbInfo.eduLength" />
						</a-form-item>
					</a-col>
					<a-col :span="12">
						<a-form-item label="学位:">
							<a-select
								v-model:value="updateMbInfo.degree" show-search :options="degreeInfo.degreeDict"
								:field-names="degreeInfo.degreeNames"
								option-filter-prop="dictLable" placeholder="请选择学位" style="width:100%">
							</a-select>

						</a-form-item>
					</a-col>
				</a-row>
			</a-card>
			<br />
			<a-card title="联系方式" style="width: 100%">
				<!--手机，邮箱-->
				<a-row :gutter="24">
					<a-col :span="12">
						<a-form-item label="手机:" labelWrap="false" name="phone"
									 :rules="[{ required: true, message: '手机号不能为空!'}]">
							<a-input v-model:value="updateMbInfo.phone" />
						</a-form-item>
					</a-col>
					<a-col :span="12">
						<a-form-item label="邮箱:">
							<a-input v-model:value="updateMbInfo.email" />
						</a-form-item>
					</a-col>
				</a-row>

				<!-- 家庭电话，办公电话-->
				<a-row :gutter="24">
					<a-col :span="12">
						<a-form-item label="家庭电话:">
							<a-input v-model:value="updateMbInfo.homeTel" />
						</a-form-item>
					</a-col>
					<a-col :span="12">
						<a-form-item label="办公电话:">
							<a-input v-model:value="updateMbInfo.officeTel" />
						</a-form-item>
					</a-col>
				</a-row>

				<!-- 紧急联系人，紧急联系人电话-->
				<a-row :gutter="24">
					<a-col :span="12">
						<a-form-item label="紧急联系人:">
							<a-input v-model:value="updateMbInfo.emergencyContact" />
						</a-form-item>
					</a-col>
					<a-col :span="12">
						<a-form-item label="紧急联系人电话:">
							<a-input v-model:value="updateMbInfo.emergencyPhone" />
						</a-form-item>
					</a-col>
				</a-row>

				<!-- 紧急联系人地址-->
				<a-row :gutter="24">
					<a-col :span="12">
						<a-form-item label="紧急联系人地址:">
							<a-input v-model:value="updateMbInfo.emergencyAddress" />
						</a-form-item>
					</a-col>
				</a-row>

			</a-card>
		</a-form>
	</a-drawer>
	<GetMb ref="getMb"></GetMb>
</template>


<script>
import member from "@/api/nft/member/member";
import { message } from "ant-design-vue";
import GetMb from "@/views/nft/member/GetMb.vue";
import fileApi from "@/api/dev/fileApi";


export default {
	name: "Meadmin",
	components: { GetMb },
	data() {
		return {
			//上传文件
			onUpload: true,
			fileList: [{
				uid: "-1",
				name: "image.png",
				status: "done",
				url: null
			}],
			number: 13,
			pagination: 11,

			labelCol: { style: { width: "110px" } },
			wrapperCol: { span: 20 },
			//列表
			columns: [
				{
					title: "账号信息",
					dataIndex: "accInfo",
					key: "accInfo"

				},
				{
					title: "区块链地址",
					dataIndex: "nativeAddress",
					key: "nativeAddress"
				},
				{
					title: "实名信息",
					dataIndex: "isKyc",
					key: "isKyc"
				},
				{
					title: "状态",
					dataIndex: "userStatus",
					key: "userStatus"
				},
				{
					title: "账号安全",
					dataIndex: "accSafety",
					key: "accSafety"
				},
				{
					title: "操作",
					key: "action"
				}
			],
			//民族下拉框
			nationInfo: {
				nationNames: { label: "dictLabel", value: "dictLabel" },
				nationDict: []
			},
			//文化程度
			cultureLevelInfo: {
				cultureLevelNames: { label: "dictLabel", value: "dictLabel" },
				cultureLevelDict: []
			},
			//政治面貌
			politicsInfo: {
				politicsNames: { label: "dictLabel", value: "dictLabel" },
				politicsDict: []
			},
			//学位
			degreeInfo: {
				degreeNames: { label: "dictLabel", value: "dictLabel" },
				degreeDict: []
			},
			//列表查出来的数据
			data: [],
			page: {
				keyword: "",
				status: "",
				pageNo: 1,
				pageSize: 5,
				total: ""
			},
			addOpen: false,
			updateOpen: false,

			//添加会员对象
			addMbInfo: {
				avatar: "",
				uuidAvatar: "",
				signature: "",
				account: "",
				password: "",
				userName: "",
				nickname: "",
				gender: "",
				age: "",
				birthday: "",
				nation: "",
				native_place: "",
				home_address: "",
				mailing_address: "",
				id_card_type: "",
				id_card_number: "",
				culture_level: "",
				political_outlook: "",
				college: "",
				education: "",
				edu_length: "",
				degree: "",
				phone: "",
				email: "",
				home_tel: "",
				office_tel: "",
				emergency_contact: "",
				emergency_phone: "",
				emergency_address: "",
				userStatus: "",
				is_kyc: ""
			},
			//修改会员对象
			updateMbInfo: {
				avatar: "",
				uuidAvatar: "",
				signature: "",
				account: "",
				nickname: "",
				userName: "",
				gender: "",
				age: "",
				birthday: "",
				nation: "",
				native_place: "",
				home_address: "",
				mailing_address: "",
				id_card_type: "",
				id_card_number: "",
				culture_level: "",
				political_outlook: "",
				college: "",
				education: "",
				edu_length: "",
				degree: "",
				phone: "",
				email: "",
				home_tel: "",
				office_tel: "",
				emergency_contact: "",
				emergency_phone: "",
				emergency_address: "",
				is_kyc: ""
			}
		};
	},
	methods: {

		// 事件: 上传文件之前
		beforeUpload(file, fileList) {
			// 显示错误提示(防抖处理)
			const showErrorMsg = debounce(this.$message.error, 20);
			验证文件大小;
			// const isLt1M = file.size / 1024 / 1024 < 2;
			// if (!isLt1M) {
			showErrorMsg("文件大小不能超出2MB");
			return false;
			// 验证文件上传数量
			if (fileList.length > 1) {
				showErrorMsg("一次上传的文件数量不能超出1个");
				return false;
			}
			return true;
		},
		//上传创作者头像
		customRequestMinio(data) {
			this.onUpload = true;
			// 转换为file类型
			const fileData = new FormData();
			fileData.append("file", data.file);
			this.addMbInfo.avatar = data.file.name;
			fileApi
				.fileUploadMinioReturnUrl(fileData)
				.then((data) => {
					this.addMbInfo.uuidAvatar = data;
				});
		},
		editCustomRequestMinio(data) {
			this.onUpload = true;
			// 转换为file类型
			const fileData = new FormData();
			fileData.append("file", data.file);
			this.updateMbInfo.avatar = data.file.name;
			fileApi
				.fileUploadMinioReturnUrl(fileData)
				.then((data) => {
					this.updateMbInfo.uuidAvatar = data;
				});
		},
		//渲染民族下拉框
		nation() {
			debugger
			member.nationList().then((resp) => {
				debugger
				this.nationInfo.nationDict = resp;
			});
			member.cultureLevelList().then((resp) => {
				debugger
				this.cultureLevelInfo.cultureLevelDict = resp;
			});
			member.politicsList().then((resp) => {
				debugger
				this.politicsInfo.politicsDict = resp;
			});
			member.degreeList().then((resp) => {
				debugger
				this.degreeInfo.degreeDict = resp;
			});
		},
		//分页查询
		query() {
			debugger
			member.queryList(this.page).then((res) => {
				this.data = res.records;
				this.page.pageSize = res.size;
				this.page.total = res.total;
			}).catch((error) => {
				debugger
				alert(error);
			});
		},
		//搜索框
		onSearch() {
			this.page.pageNo = 1;
			this.query();
		},
		//分页插件
		onChange(pageNo) {
			this.query();
			this.page.pageNo = pageNo;

		},

		//添加会员抽屉
		addMb() {
			this.nation();//词典
			this.addOpen = true;

		},
		addOnClose() {
			this.addOpen = false;
			debugger
			// this.$refs['formRef'].resetFields();
			this.addMbInfo = {
				avatar: null,
				signature: null,
				account: null,
				password: null,
				nickname: null,
				gender: null,
				age: null,
				birthday: null,
				nation: null,
				native_place: null,
				home_address: null,
				mailing_address: null,
				id_card_type: null,
				id_card_number: null,
				culture_level: null,
				political_outlook: null,
				college: null,
				education: null,
				edu_length: null,
				degree: null,
				phone: null,
				email: null,
				home_tel: null,
				office_tel: null,
				emergency_contact: null,
				emergency_phone: null,
				emergency_address: null,
				is_kyc: null
			};
		},

		//修改会员抽屉
		updateMb(type) {
			debugger
			this.nation();//词典
			member.getMember(type).then((res) => {
				this.updateMbInfo = res;
				this.fileList[0].url = this.updateMbInfo.uuidAvatar;
				this.fileList[0].name = this.updateMbInfo.avatar;
				debugger;
				console.log(resp);
			}).catch((error) => {
				error.data.data;
				console.log(error);
			});
			this.updateOpen = true;
		},
		//修改会员信息
		saveUpdateMb() {
			debugger
			//通过ref定位到from表单
			let formRef = this.$refs.formRef;
			//触发from表单的验证
			debugger
			formRef.validate().then(() => {
				debugger
				member.editMember(this.updateMbInfo).then((resp) => {
					this.query();
				}).catch((error) => {
					message.error(error);
				});
				this.updateOpen = false;
			}).catch((error) => {
				message.error("修改失败");
			});
		},
		//修改取消信息
		updateOnClose() {
			this.updateOpen = false;
			debugger
			this.$refs["formRef"].resetFields();
		},
		//添加会员信息
		saveMb() {

			debugger
			//通过ref定位到from表单
			let formRef = this.$refs.formRef;
			//触发from表单的验证
			debugger
			formRef.validate().then(() => {
				debugger
				member.addMember(this.addMbInfo).then((resp) => {
					this.query();
					this.addOpen = false;
				}).catch((error) => {
					message.error(error);
				});

			});
		},
		getMbInfo(type) {
			this.$refs.getMb.showGetMb(type);
		},
		//查看会员
		getMb(type) {
			this.$refs.getMb.showGetMb(type);
		},
		//启用
		start(type) {
			debugger
			member.startMember(type).then((resp) => {
				debugger
				this.query();
			}).catch((error) => {
				message.error(error);
			});

		},
		//禁用
		dis(type) {
			debugger
			member.disMember(type).then((resp) => {
				this.query();
			}).catch((error) => {
				message.error(error);
			});
		},
		//操作(删除)
		del(type) {
			member.delMember(type).then((resp) => {
				this.query();
			}).catch((error) => {
				debugger
				message.error(error);
			});
		}
	},
	mounted() {
		this.query();


	}
};
</script>


<style scoped>

</style>
